from typing import List, Optional, Union, Dict, Any
from pydantic import BaseModel, model_validator
from ktransformers.server.config.config import Config
from datetime import date
import json


class UserItem(BaseModel):
    user_id: str
    password: str


# 将表单数据解析为 json
class UploadItem(BaseModel):
    data: Dict

    @model_validator(mode='before')
    @classmethod
    def validate_to_json(cls, value):
        if isinstance(value, str):
            return cls(**json.loads(value))
        return value


class ReportItem(BaseModel):
    scene: Union[list, None] = None
    report_name: Union[str, None] = None
    user_id: Union[int, None] = None
    start_date: Union[date, None] = None
    end_date: Union[date, None] = None
    page_index: int
    page_size: int


class ReportCancelItem(BaseModel):
    report_id: int
    
